import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/getParameter")
public class getParameterTest extends HttpServlet {
    @Override
    //Post请求一般通过body传递，如果body中的格式是 form表单的形式，任然可以通过 getParameter 获取参数！
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //super.doGet(req, resp);
        //预期浏览器传来一个请求：/getParameter？userID=123&classID=456
        String userId = req.getParameter("userID");//获取到请求中的参数
        String classId = req.getParameter("classID");

        resp.getWriter().write("userId=" + userId + ", classId=" + classId);
    }
}
